package com.qd.panda.etc;

import com.cdqidi.dto.ApiResult;
import com.cdqidi.dto.ApiResultWrapper;
import com.cdqidi.valid.group.DefaultGroup;
import com.qd.common.sys.util.SecurityUtils;
import com.qd.common.panda.domain.entity.etc.EtcJumpDTO;
import com.qd.panda.service.etc.EtcJumpService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

/**
 * ETC/APP_跳转记录
 *
 * @author sjk
 */
@RequiredArgsConstructor
@Validated
@RestController
@RequestMapping("/app/etcJump/")
@Slf4j
public class AppEtcJumpController {
    private final EtcJumpService etcJumpService;


    /**
     * 添加跳转记录
     *
     * @param dto 页面对象
     * @return 页面对象
     */
    @PostMapping(value = "/save")
    public ApiResultWrapper<Object> save(@Validated({DefaultGroup.class}) @RequestBody EtcJumpDTO dto) {
        dto.setUserId(SecurityUtils.getLoginUser().getUserId());
        dto.setAddTime(LocalDateTime.now());
        etcJumpService.addLog(dto);
        dto.freeData();
        return ApiResult.success();
    }
}